package state;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

public class TurnStyleUsePatternTest {

	private TurnStyleUsePattern t;
	private boolean lockCalled = false;
	private boolean unlockCalled = false;
	private boolean thankyouCalled = false;
	private boolean alarmCalled = false;

	@Before
	public void setUp() throws Exception {
		TurnStyleController simController = new TurnStyleController()
		{
			public void lock() { lockCalled = true;	}
			public void unlock() { unlockCalled = true; }
			public void alarm() { alarmCalled = true; }
			public void thankyou() { thankyouCalled = true; }
		};
		t = new TurnStyleUsePattern(simController);
	}

	@Test
	public void testInitialConditions() {
		assert(t.isLocked());
	}
	
	@Test
	public void testCoinInLockedState(){
		t.setLocked();
		t.coin();
		assert(t.isUnlocked());
		assert(unlockCalled);
	}
	
	@Test
	public void testCoinInUnlockState(){
		t.setUnlocked();
		t.coin();
		assert(t.isUnlocked());
		assert(thankyouCalled);
	}
	
	@Test
	public void testPassInLockedState(){
		t.setLocked();
		t.pass();
		assert(t.isLocked());
		assert(alarmCalled);
	}
	
	@Test
	public void testPassInUnlockState(){
		t.setUnlocked();
		t.pass();
		assert(t.isLocked());
		assert(lockCalled);
	}

}
